package com.heima;

import java.util.Scanner;

public class pwdf {
    public static void main(String[] args) {
    /*
        //定义一个数组，用动态初始化完成数组元素的初始化，长度为6
        int[] arr = new int[6];
        //键盘录入评委分数
        Scanner sc = new Scanner(System.in);

        //由于是6个评委打分，所以，接收评委分数的操作，用循环改进
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个评委打分");
            int pwfs = sc.nextInt();
            if (pwfs >= 0 && pwfs <= 100) {
                arr[i] = pwfs;
            } else {
                System.out.println("输入分数错误，0-100");
                i--;//if判断错误返回for循环
            }
        }
        //求出数组最大值
        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        //求出数组最小值
        int mini = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (mini > arr[i]) {
                mini = arr[i];
            }
        }
        //求出数组之和
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        //按照计算规则进行计算得到平均分
        int pjf=(sum-max-mini)/4;

        //输出平均分
        System.out.println("平均分为："+pjf);
                                                */

        int[] arr = new int[6];
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < arr.length; i++) {
            System.out.println("输入第" + (i + 1) + "个评委分数");
            int pwdf = sc.nextInt();
            if (pwdf >= 0 && pwdf <= 100) {
                arr[i] = pwdf;
            } else {
                System.out.println("分数范围0-100，请重新输入");
                i--;
            }
        }

        int max = arr[0];
        for (int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        int mini=arr[0];
        for (int i=1;i<arr.length;i++){
            if (mini>arr[i]){
                mini=arr[i];
            }
        }
        int sum=0;
        for (int i=0;i<arr.length;i++){
           sum+=arr[i];
        }
        int pjf=(sum-max-mini)/4;
        System.out.println("平均分为："+pjf);

    }

}
